﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EagleProject.Models;
using System.IO;
using System.Web.UI.WebControls;
using EagleProject.LinQDataContext;

namespace EagleProject.Controllers
{
    public class JobSeekerController : MyController
    {
        //
        // GET: /JobSeeker/
        public ActionResult Index()
        {
            ViewBag.StateList = new SelectList(DatabaseController.GetStates(), "ID", "Name");
            ViewBag.ListEducation = ListEduction;
            ViewBag.ListTitleName = ListTitleName;
            return View();
        }

        private string GetUploadDirectory()
        {
            return "~/Upload/Application/";
        }

        //
        // POST: /JobSeeker/
        [HttpPost]
        public ActionResult Index(JobApplication model)
        {
            if (IsUploadFile())
            {
                string url = HandleFileUpload(GetUploadDirectory());
                model.DocumentURL = url;
                DatabaseController.CreateJobApplication(model);

                ViewBag.RegisterSuccess = true;
                return View("Index");
            }
            else
            {
                return View();
            }
        }
    }
}
